﻿using System;
using System.Configuration;

namespace ImageOCR
{
    /// <summary>
    /// 配置文件读取类
    /// </summary>
    class ConfigOpration
    {
        /// <summary>
        /// 找直线 允许断开距离（像素）
        /// </summary>
        public static int LineSpace = Convert.ToInt32(ConfigurationManager.AppSettings.Get("FindHorizontalLines_Space"));
        
        /// <summary>
        /// 找横线 横线最小长度与影像宽的比
        /// </summary>
        public static int HLineMinLengthRatio = Convert.ToInt32(ConfigurationManager.AppSettings.Get("FindHorizontalLines_HRatio"));

        /// <summary>
        /// 找竖线 竖线最小长度与影像高的比
        /// </summary>
        public static int VLineMinLengthRatio = Convert.ToInt32(ConfigurationManager.AppSettings.Get("FindHorizontalLines_VRatio"));

        /// <summary>
        /// 孤立直线最大长度与宽高的比
        /// </summary>
        public static int IsolateRatio = Convert.ToInt32(ConfigurationManager.AppSettings.Get("IsolateRatio"));

        /// <summary>
        /// 除横线噪音线，两线相隔最大距离
        /// </summary>
        public static int NoiseHLinesLimit = Convert.ToInt32(ConfigurationManager.AppSettings.Get("DeleteNoiseLines_H_Limit"));
        
        /// <summary>
        /// 除竖线噪音线，两线相隔最大距离
        /// </summary>
        public static int NoiseVLinesLimit = Convert.ToInt32(ConfigurationManager.AppSettings.Get("DeleteNoiseLines_V_Limit"));

        /// <summary>
        /// 直线修正 探测最大距离
        /// </summary>
        public static int CorrectLinesLimit = Convert.ToInt32(ConfigurationManager.AppSettings.Get("CorrectLinesLimit"));

        /// <summary>
        /// OCR文件保存路径,以“\”结束,如：“D:\test\Images\”
        /// </summary>
        public static string SavePath = ConfigurationManager.AppSettings.Get("SavePath");

        /// <summary>
        /// 识别精度，建议55~85
        /// </summary>
        public static int RaForEncoding = Convert.ToInt32(ConfigurationManager.AppSettings.Get("RaForEncoding"));

        /// <summary>
        /// 识别精度，建议35~55
        /// </summary>
        public static int RaForOnlyName = Convert.ToInt32(ConfigurationManager.AppSettings.Get("RaForOnlyName"));

        /// <summary>
        /// 投影行分析时，右偏移量（即从多少像素开始分析，忽略干扰）
        /// </summary>
        public static int RightOffset = Convert.ToInt32(ConfigurationManager.AppSettings.Get("RightOffset"));

        /// <summary>
        /// 上海发票类型影像行高
        /// </summary>
        public static int ShangHaiBillLineHeight = Convert.ToInt32(ConfigurationManager.AppSettings.Get("ShangHaiBillLineHeight"));

        /// <summary>
        /// 表格类型影像行高
        /// </summary>
        public static int TableDetailLineHeight = Convert.ToInt32(ConfigurationManager.AppSettings.Get("TableDetailLineHeight"));

        /// <summary>
        /// 带框类型影像行高
        /// </summary>
        public static int FrameDetailLineHeight = Convert.ToInt32(ConfigurationManager.AppSettings.Get("FrameDetailLineHeight"));

        /// <summary>
        /// 普通类型影像行高
        /// </summary>
        public static int NormalDetailLineHeight = Convert.ToInt32(ConfigurationManager.AppSettings.Get("NormalDetailLineHeight"));
    }
}
